import { getToken } from "../utils/auth"
import user from "../store/user"
import Cookies from "js-cookie"
import { Message } from 'element-ui'
/**
 * 验证用户身份信息的中间件
 */
 export default function ({ app, redirect, store }) {
  // If the user is not authenticated
  // console.log('中间件验证身份信息', store.state.user?.info?.user_info)
  // console.log('中间件验证身份信息', app.$cookies.get('info')?.user_info)
  const userInfo = app.$cookies.get('info')?.user_info || store.state.user.info?.user_info
  const token = store.state.user.token
  console.log('tokentokentokentoken', store.state.user)
  if (!token) {
    Message.warning('请您先登陆')
    redirect('/home')
  }
}
